package com.eastfair.venuebooking.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.eastfair.core.base.entity.Entity;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.venuebooking.enumeration.ContractManageContractStatusEnum;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 合同
 * </p>
 *
 * @author dqq
 * @since 2023-03-30
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("vb_contract_manage")
@ApiModel(value = "ContractManage", description = "合同")
@AllArgsConstructor
public class ContractManage extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 是否启用：1是；0否
     */
    @ApiModelProperty(value = "是否启用：1是；0否")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用：1是；0否")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;

    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 子系统id
     */
    @ApiModelProperty(value = "子系统id")
    @TableField(value = "subsystem_id")
    @Excel(name = "子系统id")
    private Long subsystemId;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @TableField(value = "tenant_id")
    @Excel(name = "租户id")
    private Long tenantId;

    /**
     * 归属人员部门id
     */
    @ApiModelProperty(value = "归属人员部门id")
    @TableField(value = "org_code")
    @Excel(name = "归属人员部门id")
    private Long orgCode;

    /**
     * 归属部门
     */
    @ApiModelProperty(value = "归属部门")
    @Size(max = 64, message = "归属部门长度不能超过64")
    @TableField(value = "org_name", condition = LIKE)
    @Excel(name = "归属部门")
    private String orgName;

    /**
     * 前归属部门ID
     */
    @ApiModelProperty(value = "前归属部门ID")
    @TableField(value = "last_org_code")
    @Excel(name = "前归属部门ID")
    private Long lastOrgCode;

    /**
     * 前归属部门名称
     */
    @ApiModelProperty(value = "前归属部门名称")
    @Size(max = 64, message = "前归属部门名称长度不能超过64")
    @TableField(value = "last_org_name", condition = LIKE)
    @Excel(name = "前归属部门名称")
    private String lastOrgName;

    /**
     * 归属人员
     */
    @ApiModelProperty(value = "归属人员")
    @TableField(value = "belong_to")
    @Excel(name = "归属人员")
    private Long belongTo;

    /**
     * 归属人姓名
     */
    @ApiModelProperty(value = "归属人姓名")
    @Size(max = 255, message = "归属人姓名长度不能超过255")
    @TableField(value = "belong_to_name", condition = LIKE)
    @Excel(name = "归属人姓名")
    private String belongToName;

    /**
     * 前归属人id
     */
    @ApiModelProperty(value = "前归属人id")
    @TableField(value = "last_belong_to")
    @Excel(name = "前归属人id")
    private Long lastBelongTo;

    /**
     * 前归属人id姓名
     */
    @ApiModelProperty(value = "前归属人id姓名")
    @Size(max = 255, message = "前归属人id姓名长度不能超过255")
    @TableField(value = "last_belong_to_name", condition = LIKE)
    @Excel(name = "前归属人id姓名")
    private String lastBelongToName;

    /**
     * 合同编号
     */
    @ApiModelProperty(value = "合同编号")
    @Size(max = 20, message = "合同编号长度不能超过20")
    @TableField(value = "contract_number", condition = LIKE)
    @Excel(name = "合同编号")
    private String contractNumber;

    /**
     * 合同名称
     */
    @ApiModelProperty(value = "合同名称")
    @Size(max = 50, message = "合同名称长度不能超过50")
    @TableField(value = "contract_name", condition = LIKE)
    @Excel(name = "合同名称")
    private String contractName;

    /**
     * 展会id
     */
    @ApiModelProperty(value = "展会id")
    @TableField(value = "exhibition_id")
    @Excel(name = "展会id")
    private Long exhibitionId;

    /**
     * 展会名称
     */
    @ApiModelProperty(value = "展会名称")
    @Size(max = 255, message = "展会名称长度不能超过255")
    @TableField(value = "exhibition_name", condition = LIKE)
    @Excel(name = "展会名称")
    private String exhibitionName;

    /**
     * 合同付款状态
     */
    @ApiModelProperty(value = "合同付款状态")
    @Size(max = 255, message = "合同付款状态长度不能超过255")
    @TableField(value = "contract_pay_state", condition = LIKE)
    @Excel(name = "合同付款状态")
    private String contractPayState;

    /**
     * 合同金额（包含场地费用场地保证金服务预付款）
     */
    @ApiModelProperty(value = "合同金额（包含场地费用场地保证金服务预付款）")
    @TableField(value = "contract_amount")
    @Excel(name = "合同金额（包含场地费用场地保证金服务预付款）")
    private BigDecimal contractAmount;

    /**
     * 合同回款金额
     */
    @ApiModelProperty(value = "合同回款金额")
    @TableField(value = "contract_returnd_amount")
    @Excel(name = "合同回款金额")
    private BigDecimal contractReturndAmount;

    /**
     * 商机id
     */
    @ApiModelProperty(value = "商机id")
    @TableField(value = "opportunity_id")
    @Excel(name = "商机id")
    private Long opportunityId;

    /**
     * 报价书id
     */
    @ApiModelProperty(value = "报价书id")
    @TableField(value = "quotation_id")
    @Excel(name = "报价书id")
    private Long quotationId;

    /**
     * 模板id
     */
    @ApiModelProperty(value = "模板id")
    @TableField(value = "contract_template_id")
    @Excel(name = "模板id")
    private Long contractTemplateId;

    /**
     * 乙方id(按客户名称查询如库里有则不为空)
     */
    @ApiModelProperty(value = "乙方id(按客户名称查询如库里有则不为空)")
    @TableField(value = "cutomer_id")
    @Excel(name = "乙方id(按客户名称查询如库里有则不为空)")
    private Long cutomerId;

    /**
     * 乙方名称
     */
    @ApiModelProperty(value = "乙方名称")
    @Size(max = 255, message = "乙方名称长度不能超过255")
    @TableField(value = "cutomer_name", condition = LIKE)
    @Excel(name = "乙方名称")
    private String cutomerName;

    /**
     * 乙方法人代表
     */
    @ApiModelProperty(value = "乙方法人代表")
    @Size(max = 255, message = "乙方法人代表长度不能超过255")
    @TableField(value = "customer_legal", condition = LIKE)
    @Excel(name = "乙方法人代表")
    private String customerLegal;

    /**
     * 乙方统一代码
     */
    @ApiModelProperty(value = "乙方统一代码")
    @Size(max = 20, message = "乙方统一代码长度不能超过20")
    @TableField(value = "customer_uscc", condition = LIKE)
    @Excel(name = "乙方统一代码")
    private String customerUscc;

    /**
     * 乙方地址
     */
    @ApiModelProperty(value = "乙方地址")
    @Size(max = 255, message = "乙方地址长度不能超过255")
    @TableField(value = "customer_address", condition = LIKE)
    @Excel(name = "乙方地址")
    private String customerAddress;

    /**
     * 主办
     */
    @ApiModelProperty(value = "主办")
    @Size(max = 255, message = "主办长度不能超过255")
    @TableField(value = "sponsor_name", condition = LIKE)
    @Excel(name = "主办")
    private String sponsorName;

    /**
     * 协办
     */
    @ApiModelProperty(value = "协办")
    @Size(max = 255, message = "协办长度不能超过255")
    @TableField(value = "undertaker_name", condition = LIKE)
    @Excel(name = "协办")
    private String undertakerName;

    /**
     * 开始时间
     */
    @ApiModelProperty(value = "开始时间")
    @TableField(value = "start_time")
    @Excel(name = "开始时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime startTime;

    /**
     * 结束时间
     */
    @ApiModelProperty(value = "结束时间")
    @TableField(value = "end_time")
    @Excel(name = "结束时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime endTime;

    /**
     * 签单日期
     */
    @ApiModelProperty(value = "签单日期")
    @TableField(value = "signing_time")
    @Excel(name = "签单日期", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime signingTime;

    /**
     * 我方签单人
     */
    @ApiModelProperty(value = "我方签单人")
    @Size(max = 255, message = "我方签单人长度不能超过255")
    @TableField(value = "signatory_name", condition = LIKE)
    @Excel(name = "我方签单人")
    private String signatoryName;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    @Size(max = 255, message = "备注长度不能超过255")
    @TableField(value = "remark", condition = LIKE)
    @Excel(name = "备注")
    private String remark;

    /**
     * 合同url
     */
    @ApiModelProperty(value = "合同url")
    @Size(max = 255, message = "合同url长度不能超过255")
    @TableField(value = "contract_url", condition = LIKE)
    @Excel(name = "合同url")
    private String contractUrl;

    /**
     * 场地保证金
     */
    @ApiModelProperty(value = "场地保证金")
    @TableField(value = "space_bond")
    @Excel(name = "场地保证金")
    private BigDecimal spaceBond;

    /**
     * 服务预存款
     */
    @ApiModelProperty(value = "服务预存款")
    @TableField(value = "service_bond")
    @Excel(name = "服务预存款")
    private BigDecimal serviceBond;

    /**
     * 场地费用
     */
    @ApiModelProperty(value = "场地费用")
    @TableField(value = "space_amount")
    @Excel(name = "场地费用")
    private BigDecimal spaceAmount;

    /**
     * 已开票金额
     */
    @ApiModelProperty(value = "已开票金额")
    @TableField(value = "invoiced_amount")
    @Excel(name = "已开票金额")
    private BigDecimal invoicedAmount;

    /**
     * 最后跟进时间
     */
    @ApiModelProperty(value = "最后跟进时间")
    @TableField(value = "last_follow_date")
    @Excel(name = "最后跟进时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime lastFollowDate;

    /**
     * 下次跟进时间
     */
    @ApiModelProperty(value = "下次跟进时间")
    @TableField(value = "next_follow_date")
    @Excel(name = "下次跟进时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime nextFollowDate;

    /**
     * 合同状态 #{SUBMIT:待审核;APPROVED:已审核;CANCEL:已作废}
     */
    @ApiModelProperty(value = "合同状态 #{SUBMIT:待审核;APPROVED:已审核;CANCEL:已作废}")
    @TableField(value = "contract_status")
    @Excel(name = "合同状态 #{SUBMIT:待审核;APPROVED:已审核;CANCEL:已作废}", replace = {"待审核_SUBMIT", "已审核_APPROVED", "已作废_CANCEL",  "_null"})
    private ContractManageContractStatusEnum contractStatus;


    @Builder
    public ContractManage(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime, 
                    Integer isEnabled, Integer isDeleted, Long projectId, Long subsystemId, Long tenantId, 
                    Long orgCode, String orgName, Long lastOrgCode, String lastOrgName, Long belongTo, String belongToName, 
                    Long lastBelongTo, String lastBelongToName, String contractNumber, String contractName, Long exhibitionId, String exhibitionName, 
                    String contractPayState, BigDecimal contractAmount, BigDecimal contractReturndAmount, Long opportunityId, Long quotationId, Long contractTemplateId, 
                    Long cutomerId, String cutomerName, String customerLegal, String customerUscc, String customerAddress, String sponsorName, 
                    String undertakerName, LocalDateTime startTime, LocalDateTime endTime, LocalDateTime signingTime, String signatoryName, String remark, 
                    String contractUrl, BigDecimal spaceBond, BigDecimal serviceBond, BigDecimal spaceAmount, BigDecimal invoicedAmount, LocalDateTime lastFollowDate, 
                    LocalDateTime nextFollowDate, ContractManageContractStatusEnum contractStatus) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
        this.projectId = projectId;
        this.subsystemId = subsystemId;
        this.tenantId = tenantId;
        this.orgCode = orgCode;
        this.orgName = orgName;
        this.lastOrgCode = lastOrgCode;
        this.lastOrgName = lastOrgName;
        this.belongTo = belongTo;
        this.belongToName = belongToName;
        this.lastBelongTo = lastBelongTo;
        this.lastBelongToName = lastBelongToName;
        this.contractNumber = contractNumber;
        this.contractName = contractName;
        this.exhibitionId = exhibitionId;
        this.exhibitionName = exhibitionName;
        this.contractPayState = contractPayState;
        this.contractAmount = contractAmount;
        this.contractReturndAmount = contractReturndAmount;
        this.opportunityId = opportunityId;
        this.quotationId = quotationId;
        this.contractTemplateId = contractTemplateId;
        this.cutomerId = cutomerId;
        this.cutomerName = cutomerName;
        this.customerLegal = customerLegal;
        this.customerUscc = customerUscc;
        this.customerAddress = customerAddress;
        this.sponsorName = sponsorName;
        this.undertakerName = undertakerName;
        this.startTime = startTime;
        this.endTime = endTime;
        this.signingTime = signingTime;
        this.signatoryName = signatoryName;
        this.remark = remark;
        this.contractUrl = contractUrl;
        this.spaceBond = spaceBond;
        this.serviceBond = serviceBond;
        this.spaceAmount = spaceAmount;
        this.invoicedAmount = invoicedAmount;
        this.lastFollowDate = lastFollowDate;
        this.nextFollowDate = nextFollowDate;
        this.contractStatus = contractStatus;
    }

}
